package org.scut.smartgeometry.utils; /**
 * Project Name:ProductCManager 
 * File Name:ToastFactory.java 
 * Package Name:com.cike.productmanager.util 
 * Date:2013-3-23上午10:14:13 
 * 
 */

import android.content.Context;
import android.widget.Toast;

/**
 * ClassName: ToastFactory <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2013-3-23 上午10:14:13 <br/>
 * 
 * @author Liang YongJian
 * @version
 * @since JDK 1.6
 * 
 *        解决toast频繁显示用户体验效果不佳的问题
 */
public class ToastFactory {
	private static Context context;
	private static Toast toast;

	public static void showToast(Context context, String title) {
		if (context == null) return;
//			context = DataApplication.getContext();
		if (ToastFactory.context == context) {
			toast.setText(title);// 重新设置内容
		} else {
			if (toast != null)// 清空之前显示的toast
				toast.cancel();
			ToastFactory.context = context;
			toast = Toast.makeText(context, title, Toast.LENGTH_SHORT);
			toast.setText(title);
		}

		toast.show();
	}


}
